package com.fer.t1.client.widgets.disqus;

import com.google.gwt.uibinder.client.UiConstructor;
import com.google.gwt.user.client.ui.HTML;

public class DisqusWidjet extends HTML{

	private Object id;
	@UiConstructor
	public DisqusWidjet(String postId) {
		super(getStaticHTML());
		this.id = postId;
	}
	
	@Override
	protected void onLoad() {
		super.onLoad();
		doScript(id);
	}
	
	static String getStaticHTML()
	{
		return "<div id=\"disqus_thread\"></div><a href=\"http://disqus.com\" class=\"dsq-brlink\">comments powered by <span class=\"logo-disqus\">Disqus</span></a>";
			    
	}
	
	public native void doScript(Object id)
	/*-{
		var disqus_identifier = id;
		
		(function() {
                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
            })();
	}-*/;

}
